package com.zh.search.controller;

import com.zh.common.annotation.Operator;
import com.zh.search.domain.dto.SearchDto;
import com.zh.search.domain.vo.SearchVo;
import com.zh.search.service.ISearchService;
import com.zh.web.base.ApiResult;
import com.zh.web.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Operator
@Api(tags = "搜索服务")
@RestController
@Validated
@RequestMapping("/search")
public class SearchController extends BaseController {

    private final ISearchService searchService;

    SearchController(ISearchService searchService) {
        this.searchService = searchService;
    }

    @PostMapping
    @ApiOperation(value = "聚合搜索")
    public ApiResult<SearchVo> search(@RequestBody SearchDto searchDto) {
        return buildSuccessPackage(searchService.doSearch(searchDto));
    }
}
